<%--
  Created by IntelliJ IDEA.
  User: 25786
  Date: 2020/7/7
  Time: 15:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>报案处理</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <link rel="icon" href="/static/images/favicon.ico">
    <link rel="stylesheet" href="/static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/layuimini.css" media="all">
    <link rel="stylesheet" href="/static/css/themes/default.css" media="all">
    <link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改</legend>
</fieldset>
<form class="layui-form" action="" lay-filter="example">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">报案编号</label>
            <div class="layui-input-inline">
                <input type="text" name="caseReportId" id="caseReportId" lay-verify="caseReportId" autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">保单号</label>
            <div class="layui-input-inline">
                <input type="text" name="warrantyId" id="warrantyId" lay-verify="warrantyId" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
             <label class="layui-form-label">报案时间</label>
             <div class="layui-input-inline">
                 <input  name="caseReportTime" id="caseReportTime" lay-verify="caseReportTime"
                        placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
             </div>
         </div>
         <div class="layui-inline">
             <label class="layui-form-label">出险时间</label>
             <div class="layui-input-inline">
                 <input  name="dangerTime" id="dangerTime" lay-verify="dangerTime" placeholder="yyyy-MM-dd"
                        autocomplete="off" class="layui-input">
             </div>
         </div>
        <div class="layui-inline">
            <label class="layui-form-label">报案人</label>
            <div class="layui-input-inline">
                <input type="text" name="reportPerson" id="reportPerson" lay-verify="reportPerson" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">报案电话</label>
            <div class="layui-input-inline">
                <input type="text" name="reportPersonTel" id="reportPersonTel" lay-verify="reportPersonTel"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">出险司机</label>
            <div class="layui-input-inline">
                <input type="text" name="driver" id="driver" lay-verify="driver" autocomplete="off" class="layui-input">
            </div>
        </div>
        <%--<div class="layui-inline">
            <label class="layui-form-label">司机电话</label>
            <div class="layui-input-inline">
                <input type="text" name="driverTel" id="driverTel" lay-verify="driverTel" autocomplete="off"
                       class="layui-input">
            </div>
        </div>--%>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>报案处理</legend>
        </fieldset>
        <div class="layui-form-item">

            <div class="layui-input-block">
                <input type="radio" lay-filter="erweima" name="jobState" value="1" title="待处理">
                <input type="radio" lay-filter="erweima" name="jobState" value="2" title="接收">
                <input type="radio" lay-filter="erweima" name="jobState" value="3" title="暂存">
                <input type="radio" lay-filter="erweima" name="jobState" value="4" title="已处理">
                <input type="radio" lay-filter="erweima" name="jobState" value="5" title="退回">
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>案件审核</legend>
        </fieldset>
        <div class="layui-input-block">
            <input type="radio" id="test1" name="claimStatus" value="1" title="已报案" >
            <input type="radio" id="test2" name="claimStatus" value="2" title="已立案" >
            <input type="radio" id="test3" name="claimStatus" value="3" title="已结案" >
            <input type="radio" id="test4" name="claimStatus" value="4" title="已撤案" >
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>提交</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            </div>
        </div>
    </div>
</form>
<script src="/static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });



        //自定义验证规则
        /*form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });*/

        //监听指定开关
       /* form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });*/

        //监听提交
        form.on('submit(demo1)', function (data) {
            var accident=data.field;
            //layer.alert(JSON.stringify(data.field));
            $.ajax({
                url: "/warranty/updateAll",
                method: "POST",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(accident),
                dataType: "json",
                success: function (result) {
                    if(result.count==0){
                        layer.alert("修改失败，保单号不存在！");
                    }else if(result.count==1){
                        layer.alert("修改成功！")
                        layer.msg(data.msg, {icon:1,time:1000}, function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload(); //刷新父页面
                            parent.layer.close(index);
                        });
                    }else if(result.count==2){
                        layer.alert("修改失败！")
                    }
                }
            });

            return false;
        });

        //表单赋值
        var datas=parent.data;
        console.log(datas);
        form.val('example', {
            "caseReportId":datas.caseReportId
            ,"warrantyId": datas.warrantyId
            ,"caseReportTime": datas.caseReportTime
            ,"dangerTime": datas.dangerTime
            ,"reportPerson": datas.reportPerson
            ,"reportPersonTel":  datas.reportPersonTel
            ,"driver": datas.driver
            //,"driverTel": datas.driverTel
            ,"jobState": datas.jobState
            ,"claimStatus": datas.claimStatus
        });



        //表单取值
        /*layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });*/
    });
</script>
</body>
</html>
